using System.Collections.Generic;
using Newtonsoft.Json;
using RestSharp;

namespace CoreLibrary.Email.Impl.Mandrill {
   
    public class Mail {
		
		[JsonProperty(PropertyName = "html")]         public string html        { get; set; }
		[JsonProperty(PropertyName = "text")]         public string text        { get; set; }
		[JsonProperty(PropertyName = "subject")]      public string subject     { get; set; }
		[JsonProperty(PropertyName = "from_email")]   public string from_email  { get; set; }
		[JsonProperty(PropertyName = "from_name")]    public string from_name   { get; set; }
        [JsonProperty(PropertyName = "bcc_address")]  public string bcc_address { get; set; }
        [JsonProperty(PropertyName = "track_opens")]  public bool track_opens   { get; set; }
		[JsonProperty(PropertyName = "track_clicks")] public bool track_clicks  { get; set; }
		[JsonProperty(PropertyName = "important")]    public bool important     { get; set; }
		[JsonProperty(PropertyName = "auto_text")]    public bool auto_text     { get; set; }
		[JsonProperty(PropertyName = "auto_html")]    public bool auto_html     { get; set; }
		[JsonProperty(PropertyName = "inline_css")]   public bool inline_css    { get; set; }
		[JsonProperty(PropertyName = "tags")]         public List<string> tags  { get; private set; }
		[JsonProperty(PropertyName = "to")]           public List<MailRecipient> to { get; private set; }
		[JsonProperty(PropertyName = "attachments")]  public List<MailAttachment> attachments { get; private set; }
		[JsonProperty(PropertyName = "headers")]      public JsonObject headers { get; private set; }
		[JsonProperty(PropertyName = "metadata")]     public JsonObject metadata{ get; private set; }

	    public void AddHeader(string name, string value) {
            if (headers == null) {
                headers = new JsonObject();
            }
            headers[name] = value;
        }

        public void AddMetaData(string name, string value) {
            if(metadata == null) {
               metadata = new JsonObject();
            }
            metadata[name] = value;
        }

        public void AddRecipient(MailRecipient mailRecipient) {
            if (to == null) {
                to = new List<MailRecipient>();
            }
            to.Add(mailRecipient);
        }

        public void AddAttachement(MailAttachment attachement) {
            if (attachments == null) {
                attachments = new List<MailAttachment>();
            }
            attachments.Add(attachement);
        }

        public void AddTag(string tag) {
            if (CollectionUtil.IsEmpty(tags)) {
                tags = new List<string>();
            }
            tags.Add(tag);
        }

    }

}